/*
 * Copyright (C) 2023 ab_skywalker@163.com All Rights Reserved.
 *
 * SPDX-License-Identifier: MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */
#ifndef __FOC_PARK_CLARK_H
#define __FOC_PARK_CLARK_H

#include <stdint.h>

typedef struct {
    int16_t a;
    int16_t b;
    int16_t c;
}DIM_THREE_S;

typedef struct {
    int16_t alpha;
    int16_t beta;
}DIM_TWO_S;

typedef struct {
    int16_t q;
    int16_t d;
}DIM_ROTATE_S;

void clarkTransform(DIM_THREE_S origincur, DIM_TWO_S *cur);
void parkTransform(DIM_TWO_S origincur, int32_t pahse, DIM_ROTATE_S *cur);
void reserveParkTransform(DIM_ROTATE_S originvol, int32_t pahse, DIM_TWO_S *vol);
void svpwmTransform(DIM_TWO_S vol, DIM_THREE_S *duty);
uint8_t foc_getSector(uint16_t phase);
#endif
